package org.ghost.spring.cloud.hystrix.demo.service.impl;

import feign.hystrix.FallbackFactory;
import org.ghost.spring.cloud.hystrix.demo.dto.RspDTO;
import org.ghost.spring.cloud.hystrix.demo.dto.weather.WeatherDTO;
import org.ghost.spring.cloud.hystrix.demo.service.IDemoService;
import org.springframework.stereotype.Service;

@Service
public class DemoServiceFallbackFactory implements FallbackFactory<IDemoService> {
    @Override
    public IDemoService create(Throwable cause) {
        return new IDemoService() {
            @Override
            public RspDTO get(String id) {
                return new RspDTO("Fallback->" + id);
            }

            @Override
            public RspDTO post(WeatherDTO reqDTO) {
                return new RspDTO("Fallback->" + reqDTO);
            }

            @Override
            public RspDTO put(String id, WeatherDTO reqDTO) {
                return new RspDTO("Fallback->" + reqDTO);
            }

            @Override
            public RspDTO delete(String id) {
                return new RspDTO("Fallback->" + id);
            }

            @Override
            public String test1() {
                return "Fallback->test1";
            }

            @Override
            public RspDTO test2() {
                return new RspDTO("Fallback->test2");
            }

            @Override
            public RspDTO test3() {
                return new RspDTO("Fallback->test3");
            }

            @Override
            public RspDTO test4() {
                return new RspDTO("Fallback->test4");
            }
        };
    }
}
